<?php
function __autoload($class_name)
{
	//Mirar en el directorio de las clases
	foreach(scandir("clases") as $directory)
	{
		$directory="clases/".$directory."/";
		//Si lo encuentra, lo incluye
		if(file_exists($directory.$class_name . '.php'))
		{
			require_once($directory.$class_name . '.php');
			return;
		}   
	}
}

include("conexion.php");

$sesion=new Sesion();
if(!$sesion->iniciar())
{
	include("plantillas/portada.php");
	exit;
}


if($_GET['seccion']=="")
{
?>
<html>
<head>

      <link href="css/inettuts.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="plantillas/<?php echo $sesion->getUsuario()->getTema();?>/css/principal.css" />


<!-- Cutrenti -->

	
	<script type="text/javascript" src="js/jquery-1.2.6.min-min.js"></script>
	<script type="text/javascript" src="js/jquery-ui-1.7.1.custom.min.js"></script>
	  
      <script type="text/javascript" src="js/jquery-ui-personalized-1.6rc2.min-min.js"></script>
	  <script type="text/javascript" src="js/jquery.history.js"></script>
      <script type="text/javascript" src="js/inettuts.js"></script>
      <script type="text/javascript" src="js/cookie.jquery-min.js"></script>
      
      <script type="text/javascript" src="js/jeip.js"></script>
      
      <!-- menu de invitar amigos eventos -->
	<link rel="stylesheet" href="css/common.css" type="text/css" />
	<link type="text/css" rel="stylesheet" href="http://jqueryui.com/themes/base/ui.all.css" />
	<link type="text/css" href="css/ui.multiselect.css" rel="stylesheet" />


	<script type="text/javascript" src="js/plugins/localisation/jquery.localisation-min.js"></script>
	<script type="text/javascript" src="js/plugins/scrollTo/jquery.scrollTo-min.js"></script>
	<script type="text/javascript" src="js/ui.multiselect.js"></script>


      
      
	  <script type="text/javascript" src="js/Tipmage-1.0.js"></script>	  
<link href="css/cutrenti.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/cutrenti.js"></script>	  	

<script>

</script>	  
<!-- YUI -->
<!-- Combo-handled YUI CSS files: -->
<!-- Con paginator<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.7.0/build/fonts/fonts-min.css&2.7.0/build/autocomplete/assets/skins/sam/autocomplete.css&2.7.0/build/button/assets/skins/sam/button.css&2.7.0/build/calendar/assets/skins/sam/calendar.css&2.7.0/build/slider/assets/skins/sam/slider.css&2.7.0/build/colorpicker/assets/skins/sam/colorpicker.css&2.7.0/build/container/assets/skins/sam/container.css&2.7.0/build/paginator/assets/skins/sam/paginator.css&2.7.0/build/datatable/assets/skins/sam/datatable.css"> -->
<!-- Combo-handled YUI JS files: -->
<!--<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.7.0/build/yahoo-dom-event/yahoo-dom-event.js&2.7.0/build/animation/animation-min.js&2.7.0/build/connection/connection-min.js&2.7.0/build/datasource/datasource-min.js&2.7.0/build/autocomplete/autocomplete-min.js&2.7.0/build/element/element-min.js&2.7.0/build/button/button-min.js&2.7.0/build/calendar/calendar-min.js&2.7.0/build/dragdrop/dragdrop-min.js&2.7.0/build/slider/slider-min.js&2.7.0/build/colorpicker/colorpicker-min.js&2.7.0/build/container/container-min.js&2.7.0/build/cookie/cookie-min.js&2.7.0/build/paginator/paginator-min.js&2.7.0/build/datatable/datatable-min.js&2.7.0/build/json/json-min.js&2.7.0/build/uploader/uploader.js"></script>-->
<!-- Combo-handled YUI CSS files: -->
<!-- Sin paginator -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.7.0/build/fonts/fonts-min.css&2.7.0/build/autocomplete/assets/skins/sam/autocomplete.css&2.7.0/build/button/assets/skins/sam/button.css&2.7.0/build/calendar/assets/skins/sam/calendar.css&2.7.0/build/slider/assets/skins/sam/slider.css&2.7.0/build/colorpicker/assets/skins/sam/colorpicker.css&2.7.0/build/container/assets/skins/sam/container.css&2.7.0/build/datatable/assets/skins/sam/datatable.css">
<!-- Combo-handled YUI JS files: -->
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.7.0/build/yahoo-dom-event/yahoo-dom-event.js&2.7.0/build/animation/animation-min.js&2.7.0/build/connection/connection-min.js&2.7.0/build/datasource/datasource-min.js&2.7.0/build/autocomplete/autocomplete-min.js&2.7.0/build/element/element-min.js&2.7.0/build/button/button-min.js&2.7.0/build/calendar/calendar-min.js&2.7.0/build/dragdrop/dragdrop-min.js&2.7.0/build/slider/slider-min.js&2.7.0/build/colorpicker/colorpicker-min.js&2.7.0/build/container/container-min.js&2.7.0/build/cookie/cookie-min.js&2.7.0/build/datatable/datatable-min.js&2.7.0/build/json/json-min.js&2.7.0/build/uploader/uploader.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.7.0/build/yahoo-dom-event/yahoo-dom-event.js&amp;2.7.0/build/animation/animation-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/menu/menu-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/tabview/tabview-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/imageloader/imageloader-min.js"></script>

<script type="text/javascript" src="/js/paginator.js"></script>
<script type="text/javascript" src="/js/uploader_funciones.js"></script>

<!-- chat (optimizar) -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/menu/assets/skins/sam/menu.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/tabview/assets/skins/sam/tabview.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/button/assets/skins/sam/button.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/container/assets/skins/sam/container.css" />

<!-- botones -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/button/assets/skins/sam/button.css">
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/yahoo-dom-event/yahoo-dom-event.js"></script> 
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/element/element-min.js"></script> 
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/button/button-min.js"></script> 

<!--- FIN YUI -->
<script type="text/javascript" src="/js/widget.alert.js"></script>

<script type="text/javascript" src="/js/widget.mensaje.js"></script>

		  <!-- CHAT -->
<!-- barra -->
<script type="text/javascript" src="/js/interface.js"></script>
<link href="css/dock.css" rel="stylesheet" type="text/css" />
<!-- fin barra -->

<!--- lava lamp -->
    <script type="text/javascript" src="js/jquery.easing.min.js"></script>
    <script type="text/javascript" src="js/jquery.lavalamp.js"></script>
    <link rel="stylesheet" href="lava/lavalamp_test.css" type="text/css" media="screen">

<!--- lava lamp -->
		 <script type='text/javascript' src='js/b64.js'></script>
<script type='text/javascript' src='js/md5.js'></script>
  <script type='text/javascript'
	  src='js/strophe.js'></script>
  <script type='text/javascript'
	  src='js/chat-jabber.js'></script>
	 
	 
<script language="javascript" type="text/javascript" src="js/ynf.js"></script>

<!--Cargado sin comprirmi -->
<script type="text/javascript" src="/js/tiny_mce/tiny_mce.js"></script>

<script>
var miTema = "<?php echo $sesion->getUsuario()->getTema();?>";

		//Para el login inicial
		if(document.location.toString().indexOf("perfil") == -1 && document.location.toString().indexOf("foto") == -1)
		{
			//El widget blog se encarga de cargar el estilo
			if(miTema == "personalizada")
			{
				cargarEstilo(miTema,<?php echo $sesion->getUsuario()->getId(); ?>);
			}else{
				cargarEstilo(miTema);
			}
			
		}
	</script>
	


</head>

<body class=" yui-skin-sam" bgcolor="#DEE6F3">

<input type="hidden" id="idUsuario" value="<?php echo $sesion->getUsuario()->getId(); ?>">
<!-- Para copiar el formato del usuario si hace falta -->
<? echo $sesion->getUsuario()->escribir(""); ?>

<br />

<table id="barra" class="barraTabla" width="100%">
	<tr><td width="20%">
	<ul class="lavaLampWithImage" id="menuLava">
		<li id="lavaInicio" class="current"><a class="lava" onclick="$.historyLoad('seccion=inicio');" href="javascript:void(0)">Inicio</a></li>
		<li id="lavaPerfil"><a class="lava" onclick="$.historyLoad('seccion=perfil');" href="javascript:void(0)">Mi Perfil</a></li>
		<li id="lavaBuscar"><a class="lava" onclick="$.historyLoad('seccion=buscar');" href="javascript:void(0)">Gente</a></li>
	</ul>
	</td>
<td width="60%">
				<div class="dock" id="dock">
  <div class="dock-container">
  <a class="dock-item" rel="history" href="#seccion=fotos"><img src="images/fotos.png" alt="Fotos" /><span>Fotos</span></a> 
  <a class="dock-item" rel="history" href="#seccion=perfil"><img src="images/multimedia.png" alt="Multimedia" /><span>Multimedia</span></a> 
  <a class="dock-item" rel="history" href="#seccion=mensajesPrivados"><img src="images/mensajes.png" alt="Mensajes" /><span>Mensajes</span></a> 
  <a class="dock-item" href="javascript:void(0)" onclick="mostrarPanelSubirFotos()"><img src="images/subir-fotos.png" alt="Subir Fotos" /><span>Subir fotos</span></a> 
  <a class="dock-item" rel="history" href="#seccion=cuenta"><img src="images/configuracion.png" alt="Cuenta" /><span>Cuenta</span></a> 
  <a class="dock-item" href="/salir"><img src="images/salir.png" alt="Salir" /><span>Salir</span></a> 
</div>
</div>
<div id="myAutoComplete">
	 <input id="myInput" type="text" value="Buscar" onkeyup="{if (event.keyCode==13)buscarPersona()}" onclick="this.value=''" onblur="{if(this.value.length==0)this.value='Buscar'}"> 
	<div id="myContainer"></div>
	<input id="myHidden" type="hidden">
</td>
<td width="20%">


		    <!-- CHAT -->
  

<div><a href="javascript:void(0)" onclick="cambiarTamChat()">Amigos Conectados</a><span id="totalConectados">(0)</span>
<a href="javascript:void(0)" onclick="mostrarConversaciones()"><img id="barraEstado" border="0"/></a>
<a href="javascript:void(0)" id="menuChatOpciones"><img id="imagenMenu"/></a>
<div style="position:fixed" id="situacionMenuChat"></div>

</div>

<div style="position:fixed;border:1px solid red; background-color: #ffffff" id="listaAmigosChat">
</div>
	
  <div id="chatConversaciones">
	<div class="hd">Conversaciones</div>
	<div class="bd">
		<div id="demo" class="yui-navset">
			<ul class="yui-nav">


			</ul>            
			<div class="yui-content">
			</div>
		</div>

	</div>
  </div>
<!-- CHAT fin -->
		</td>
	</tr>
</table>
<br />
<div id="respuesta"></div>

<div class="estado"><span id="mensajeEstado">Cargando</span></div>
<script type="text/javascript">
$(document).ready(function() {
	$(".estado").hide();
});
//Autocompletador
    YAHOO.example.amigos = [

	<?php
	//Creamos el json de los usuarios
	$listaAmigos=$sesion->getUsuario()->getListaAmigos(0);
	foreach($listaAmigos as $amigo)
	{
		$amigosJson.='{id:'.$amigo->getId().', fname:"'.$amigo->getNombre().'", lname:"'.$amigo->getApellido1().'", nname:null},';
	}
        echo rtrim($amigosJson,",");
	?>
    ];

</script>
	</body>
</html>
<?php
}
else
{
	foreach($_GET as $clave => $valor)
	{
		//Dejar solo letras y numeros
		$_GET[$clave]=mysql_real_escape_string(ereg_replace("[^A-Za-z0-9]", "", $valor ));
	}
	
	foreach($_POST as $clave => $valor)
	{
		//Eliminar el tag script
		$_POST[$clave]=mysql_real_escape_string(ereg_replace("<script.","", $valor));
		//$_POST[$clave]=mysql_real_escape_string(ereg_replace("<iframe.","", $valor));
	}
	
   $xslDoc = new DOMDocument();
   $xslDoc->load("plantillas/predeterminada/".$_GET['seccion'].".xsl");

   $xmlDoc = new DOMDocument();
   

   $xmlDoc->loadXML(include("secciones/".$_GET['seccion'].".php"));

   $proc = new XSLTProcessor();
   $proc->importStylesheet($xslDoc);
   echo utf8_decode(htmlspecialchars_decode($proc->transformToXML($xmlDoc)));
}

